# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=elidecode
pkgver=48.38fa5ba
pkgrel=6
groups=('blackarch' 'blackarch-reversing')
arch=('any')
pkgdesc='A tool to decode obfuscated shellcodes using the unicorn-engine for the emulation and the capstone-engine to print the asm code.'
url='https://github.com/DeveloppSoft/EliDecode'
license=('GPL3')
depends=('python2' 'python2-unicorn' 'python2-argparse' 'python2-capstone'
         'python2-setuptools' 'capstone' 'unicorn' 'bash')
makedepends=('git')
source=("$pkgname::git+https://github.com/DeveloppSoft/EliDecode.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm LICENSE

  cp -a --no-preserve=ownership * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/usr/bin/env bash
cd /usr/share/$pkgname
exec python2 decoder.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

